<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::dropIfExists('scm_devices');
        Schema::create('scm_devices', function (Blueprint $table) {
            $table->bigIncrements('id')->comment('主键自动增长');
            $table->bigInteger('org_id')->index()->default(0)->comment('组织ID');
            $table->unsignedInteger('status')->default(1)->comment('状态');
            $table->text('extra_data')->nullable()->comment('扩展数据，格式为json');
            $table->timestamps();
            $table->softDeletes();
            $table->engine = 'InnoDB';
            $table->charset = 'utf8mb4';
            $table->collation = 'utf8mb4_unicode_ci';
        });
        DB::statement("ALTER TABLE scm_devices comment 'SCM 设备表';");

        Schema::dropIfExists('scm_device_binds');
        Schema::create('scm_device_binds', function (Blueprint $table) {
            $table->bigIncrements('id')->comment('主键自动增长');
            $table->string('bind_id', 191)->index()->nullable()->default(0)->comment('绑定ID');
            $table->unsignedInteger('status')->default(1)->comment('状态');
            $table->text('extra_data')->nullable()->comment('扩展数据，格式为json');
            $table->timestamps();
            $table->softDeletes();
            $table->engine = 'InnoDB';
            $table->charset = 'utf8mb4';
            $table->collation = 'utf8mb4_unicode_ci';
        });
        DB::statement("ALTER TABLE scm_device_binds comment 'SCM 设备绑定表';");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
};
